import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("menu", { schema: "small_tail_admin" })
export class Menu {
  @PrimaryGeneratedColumn({ type: "int", name: "id", comment: "主键 ID" })
  id: number;

  @Column("int", { name: "parent_id", nullable: true, comment: "父级菜单 ID" })
  parentId: number | null;

  @Column("tinyint", {
    name: "type",
    comment: "菜单类型 1:目录;2:菜单;3:iframe;4:外链;",
  })
  type: number;

  @Column("varchar", { name: "name", comment: "菜单名称", length: 20 })
  name: string;

  @Column("varchar", {
    name: "page_path",
    nullable: true,
    comment: "页面路径",
    length: 255,
  })
  pagePath: string | null;

  @Column("varchar", {
    name: "route_name",
    nullable: true,
    comment: "路由名称",
    length: 50,
  })
  routeName: string | null;

  @Column("varchar", {
    name: "route_path",
    nullable: true,
    comment: "路由路径",
    length: 255,
  })
  routePath: string | null;

  @Column("text", { name: "route_query", nullable: true, comment: "路由参数" })
  routeQuery: string | null;

  @Column("text", { name: "link_path", nullable: true, comment: "链接路径" })
  linkPath: string | null;

  @Column("int", {
    name: "sort",
    comment: "排序，数字越大优先级越高",
    default: () => "'0'",
  })
  sort: number;

  @Column("tinyint", {
    name: "icon_type",
    nullable: true,
    comment: "图标类型 1:iconify图标;2:文本图标;3:链接图标;",
  })
  iconType: number | null;

  @Column("text", { name: "icon", nullable: true, comment: "图标" })
  icon: string | null;

  @Column("tinyint", {
    name: "disabled",
    comment: "是否禁用",
    width: 1,
    default: () => "'0'",
  })
  disabled: boolean;

  @Column("tinyint", {
    name: "hidden",
    comment: "是否隐藏",
    width: 1,
    default: () => "'0'",
  })
  hidden: boolean;

  @Column("tinyint", {
    name: "cached",
    comment: "是否缓存",
    width: 1,
    default: () => "'0'",
  })
  cached: boolean;

  @Column("tinyint", {
    name: "labeled",
    comment: "是否开启标签页",
    width: 1,
    default: () => "'0'",
  })
  labeled: boolean;

  @Column("int", {
    name: "label_sort",
    comment: "在标签页中的排序",
    default: () => "'0'",
  })
  labelSort: number;

  @Column("tinyint", {
    name: "deleted",
    comment: "是否删除",
    width: 1,
    default: () => "'0'",
  })
  deleted: boolean;

  @Column("datetime", {
    name: "create_time",
    comment: "创建时间",
    default: () => "CURRENT_TIMESTAMP",
  })
  createTime: Date;

  @Column("datetime", {
    name: "update_time",
    comment: "更新时间",
    default: () => "CURRENT_TIMESTAMP",
  })
  updateTime: Date;

  @Column("datetime", {
    name: "delete_time",
    nullable: true,
    comment: "删除时间",
  })
  deleteTime: Date | null;
}
